Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
Insecure CSP value "'unsafe-eval'" in directive 'script-src'

while trying to load a third-party js file into content scripts in chrome extension. I'm facing an unsafe-eval error

My manifest.json looks like this

{
    "manifest_version": 3,
    "name": "Test",
    "version": "1.0",
    "host_permissions": ["https://mail.google.com/"],
    "content_scripts": [
        {
            "matches": [
                "https://mail.google.com/*"
            ],
            "js": ["3rdparty.js", "code.js"],
            "run_at": "document_end"
        }
    ]
}

after loading I'm receiving this error

Error logged: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".

so, I have tried adding csp to the manifest file

{
...,
"content_security_policy": {
    "extension_pages": "script-src 'self' 'unsafe-eval'; object-src 'self'"
  }
}

then I'm receiving this error in chrome telling that its unable to load the extension

'content_security_policy.extension_pages': Insecure CSP value "'unsafe-eval'" in directive 'script-src'.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm afraid you cannot use 'unsafe-eval' in manifest version 3

Are you executing remote code or arbitrary strings? You can no longer execute external logic using chrome.scripting.executeScript({code: '...'}), eval(), and new Function().

You have to move all your script into remote or local files. You may generate scripts on a remote file (eg. php) and execute it using chrome.scripting.executeScript instead of using eval() or consider migrating back to MV2.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda